package com.render.gui;

import base.render.CosineWiggle;
import base.render.gui.GuiButton;
import base.world.World;

import com.world.WorldLoadTest;

public class GuiButtonLoadTest extends GuiButton
{
	private CosineWiggle theWiggle;
	private float origX = 0;
	
	private boolean timeToExit = false;
	
	public GuiButtonLoadTest(int par1, int par2, int par3)
	{
		super(par1, par2, par3, "Load Test");
		
		this.theWiggle = new CosineWiggle(this.rand);
		this.origX = getWindowWidth() / 2 - this.getLabelLength() / 2;
	}
	
	public void onUpdate()
	{
		super.onUpdate();
		if (this.timeToExit)
		{
			this.x += this.x / 32;
			if (this.x > getWindowWidth() + this.getLabelLength())
			{
				this.doUpdate(2);
			}
			return;
		}
		
		if (this.isCurrentButton(this.buttonID, this.getWorldButton()))
		{
			this.x = (int) (this.origX + this.theWiggle.doTheWiggle());
		}
		else
		{
			this.theWiggle.resetTheWiggle();
			this.x = (int) this.origX;
		}
	}
	
	public void doUpdate(int par1)
	{
		switch(par1)
		{
		case 1:
			this.timeToExit = true;
			break;
		case 2:
			World.moveToWorld(this.getWorldObj(), new WorldLoadTest());
			break;
		default:
			System.out.println(this.label);
			break;
		}
	}
}
